using System.Collections.Generic;
using System.Linq;
using UnityEngine;


    [CreateAssetMenu(fileName = "FriendTargetInSkillRange-获得这个技能范围的己方", menuName = "Skill/Target/FriendTargetInSkillRange-获得在这个技能范围的己方")]
    public class FriendInSkillRangeTarget : TargetSelectorBase
    {
        public override List<Chess> SelectTargets(Chess chess ,GameEvent e)
        {
            var chessList = ChessManager.GetInstance().chessList;
            var friendchess = chessList.Where(c => c.GetChessSide() == chess.GetChessSide()).ToList();
            var targetPositions =
                chess.GetChessSide() == ChessSide.Player1
                    ? chess.chessDate.skillRange.rangeType == RangeType.Normal
                        ? Math.GetTargetPosition(chess.ChessDetail.Position,
                            chess.chessDate.skillRange.vector2IntMode)
                        : chess.chessDate.skillRange.vector2IntMode
                    : chess.chessDate.skillRange.rangeType == RangeType.Normal
                        ? Math.GetEnemyTargetPosition(chess.ChessDetail.Position,
                            chess.chessDate.skillRange.vector2IntMode)
                        : chess.chessDate.skillRange.vector2IntMode;
            var targets = (from targetChess in friendchess
                where targetPositions.Contains(targetChess.ChessDetail.Position)
                select targetChess).ToList();

            return targets;
        }
        
        
        
        
        
    }
